package com.mvc.demo;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MatchDemo {

    public static void main(String[] args) {
        StringBuffer sb = new StringBuffer();
        String line ="My name is @{name},Addr= @{addr},@{addr}";

            Matcher m = matcher(line);
            while (m.find()) {
                for (int i = 1; i <= m.groupCount(); i ++) {
                    String paramName = m.group(i);
//                    Object paramValue = mv.getModel().get(paramName);
//                    if(null == paramValue){ continue; }
//                    line = line.replaceAll("@\\{" + paramName + "\\}", paramValue.toString());
                    System.out.println(paramName);
                }
            }

            sb.append(line);

    }
    public static Matcher matcher(String str) {
        Pattern pattern =Pattern.compile("@\\{(.+?)\\}",Pattern.CASE_INSENSITIVE);
        return pattern.matcher(str);
    }
}
